import { request } from '../request';

const mockOriginList = [
  {
    guid: '054c22989d8845af9981126d687e0cea',
    name: '河北茂生成林园林绿化有限公司',
    type: 100,
    parentId: '0',
    entId: '1ae24d7b8e1b4c5fa0592f263815fea3',
    level: 1,
    orgnList: null,
    driverNum: 0,
  },
  {
    guid: '1856e0ab53444edd9be4b1205ec52665',
    name: '行',
    type: 100,
    parentId: '054c22989d8845af9981126d687e0cea',
    entId: '1ae24d7b8e1b4c5fa0592f263815fea3',
    level: 2,
    orgnList: null,
    driverNum: 0,
  },
  {
    guid: '3b5f9a9e1e1f409bbe8f5efd5c9c01cc',
    name: '浙江大部门',
    type: 100,
    parentId: '054c22989d8845af9981126d687e0cea',
    entId: '1ae24d7b8e1b4c5fa0592f263815fea3',
    level: 2,
    orgnList: null,
    driverNum: 0,
  },
  {
    guid: '78741ed5b4e04a91ae26dd987185e062',
    name: '上海大部门',
    type: 100,
    parentId: '054c22989d8845af9981126d687e0cea',
    entId: '1ae24d7b8e1b4c5fa0592f263815fea3',
    level: 2,
    orgnList: null,
    driverNum: 0,
  },
  {
    guid: '804e03c1ac854c8695b333d1c5c71f84',
    name: '总部仓库',
    type: 100,
    parentId: '054c22989d8845af9981126d687e0cea',
    entId: '1ae24d7b8e1b4c5fa0592f263815fea3',
    level: 2,
    orgnList: null,
    driverNum: 0,
  },
  {
    guid: '8b8f52d2ca1d47f7b70038dea40e7763',
    name: '凤凰咀',
    type: 100,
    parentId: '78741ed5b4e04a91ae26dd987185e062',
    entId: '1ae24d7b8e1b4c5fa0592f263815fea3',
    level: 3,
    orgnList: null,
    driverNum: 0,
  },
  {
    guid: 'b0f4ea87db884fb8bb818423c941b853',
    name: '杭州中部门',
    type: 100,
    parentId: '3b5f9a9e1e1f409bbe8f5efd5c9c01cc',
    entId: '1ae24d7b8e1b4c5fa0592f263815fea3',
    level: 3,
    orgnList: null,
    driverNum: 0,
  },
  {
    guid: 'f4570b24576544bc8371ab5fe50f7a08',
    name: '急哦哈',
    type: 100,
    parentId: '8b8f52d2ca1d47f7b70038dea40e7763',
    entId: '1ae24d7b8e1b4c5fa0592f263815fea3',
    level: 4,
    orgnList: null,
    driverNum: 0,
  },
];

type OrgItem = {
  guid: string;
  name: string;
  type: number;
  parentId: string;
  entId: string;
  level: number;
  driverNum: number;
};

async function getOrgnList(params: any) {
  const { data } = await request<{ orgnList: OrgItem[] }>({
    url: '/safe/api/entOrgn/getOrgnList',
    params,
  });
  return data.orgnList ?? []; //mockOriginList
}

async function getOrgnParent(params: any) {
  const { data } = await request<any>({
    url: '/safe/api/entEnterprise/getEntInfo',
    method: 'get',
    params,
  });
  return data;
}
export { getOrgnList, getOrgnParent };
